var tab = null;
var accordion = null;
var tree = null;
var indexdata = [
             	{ 
             		text: '模板和域', isexpand: true, children: [
             		{ url: "/introduction/init", text: "业务介绍" },
             		{ url: "/template/query", text: "模板配置" },
             		{ url: "/domain/list", text: "域配置" },
             		{ url: "/apptemplate/query", text: "应用模板配置" },
             		//{ url: "/appdomaintemplate/list", text: "应用模板和域" },
             		{ url: "/domainappchannel/list", text: "域渠道关系" },
             		{ url: "/channel/query", text: "应用渠道配置" }
                ]},
                {
			    	 text: '任务配置', isexpand: true, children: [
                     { url: "/task/index", text: "任务管理" }
			     ]},
			     
			      {
			    	 text: '群配置', isexpand: true, children: [
                    { url: "/group/index", text: "群管理" },
             		{ url: "/groupuser/index", text: "群用户关系" },
             		{ url: "/groupapp/index", text: "群渠道关系" }
			     ]},
			     
			  	{
			    	 text: '历史消息', isexpand: true, children: [
                     { url: "/order/history/list", text: "历史消息" },
                     { url: "/order/schedule/list", text: "待发送消息" },
                     { url: "/message/index", text: "消息重发管理" }
			     ]},
			     {
                	text: '阀值管理', isexpand: true, children: [
                    { url: "/throttle/query", text: "阀值管理" }
			     ]},
 
			     {
			    	 text: '分类管理', isexpand: true, children: [
			    	 { url: "/category/query", text: "分类列表" }
			     ]},
 
			     {
                	text: '证书管理', isexpand: true, children: [
                    { url: "/certificate/query", text: "证书配置" }
			     ]},
			     {
                	text: '队列状态', isexpand: true, children: [
                    { url: "/queue/statistics", text: "队列状态查询" }
			     ]},
			     {
                	text: '用户分组', isexpand: true, children: [
                    { url: "/class/query", text: "用户分组" }
			     ]},
			  	 {
                	text: '消息广播', isexpand: true, children: [
                    { url: "/classmsg/add", text: "新建广播消息" },
                    { url: "/classmsg/sending/query", text: "待发送消息" },
                    { url: "/classmsg/sent/query", text: "已发送消息" }
			     ]}
             ];


$(document).ready(function(){ 

	//布局
	$("#layout1").ligerLayout({
		leftWidth : 190,
		height : '100%',
		heightDiff : -34,
		space : 4,
		onHeightChanged : f_heightChanged
	});

	var height = $(".l-layout-center").height();
	//Tab
	$("#framecenter").ligerTab({
		height : height
	});

	//面板
	$("#accordion1").ligerAccordion({
		height : height - 24,
		speed : null
	});

	$(".l-link").hover(function() {
		$(this).addClass("l-link-over");
	}, function() {
		$(this).removeClass("l-link-over");
	});
	//树
	$("#tree1").ligerTree({
		data : indexdata,
		checkbox : false,
		slide : false,
		nodeWidth : 120,
		attribute : [ 'nodename', 'url' ],
		onSelect : function(node) {
			if (!node.data.url)
				return;
			var tabid = $(node.target).attr("tabid");
			if (!tabid) {
				tabid = new Date().getTime();
				$(node.target).attr("tabid", tabid)
			}
			f_addTab(tabid, node.data.text, node.data.url);
		}
	});
	tab = $("#framecenter").ligerGetTabManager();
	accordion = $("#accordion1").ligerGetAccordionManager();
	tree = $("#tree1").ligerGetTreeManager();
	$("#pageloading").hide();
	$("#framecenter").find("#home").attr("src","/welcome");

});

function f_heightChanged(options) {
	if (tab)
		tab.addHeight(options.diff);
	if (accordion && options.middleHeight - 24 > 0)
		accordion.setHeight(options.middleHeight - 24);
}
function f_addTab(tabid, text, url) {
	tab.addTabItem({
		tabid : tabid,
		text : text,
		url : $rmsServer+url
	});
}
